package com.chocho.producerserver.utils;

import com.chocho.producerserver.config.RabbitConfig;
import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @Auther: qiuzp
 * @Date: 19-1-5 下午2:09
 * @Description:主要用于消息的发送
 */
@Service
public class MQSend {
    @Autowired
    private AmqpTemplate rabitmqTemplet;

    /**
     * 将任何对象先使用字符串序列化方式处理再进行传送
     *
     * @param message
     */
    public void sendMessage(String message) throws Exception {
        rabitmqTemplet.convertAndSend(RabbitConfig.queueName, message);
    }
}
